package com.chaihu.admin.service.impl.menugroup;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chaihu.admin.dao.MenuGroupServiceDao;
import com.chaihu.bean.dto.admin.MenuGroupDto;
import com.chaihu.bean.in.admin.menugroup.DeleteMenuGroupIn;
import com.chaihu.bean.result.ResponseResult;
import com.chaihu.intf.admin.menugroup.DeleteMenuGroupService;
import com.chaihu.intf.icommon.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class DeleteMenuGroupServiceImpl extends BaseService<ResponseResult<Void>, DeleteMenuGroupIn> implements DeleteMenuGroupService {
    @Autowired
    private MenuGroupServiceDao menuGroupServiceDao;

    @Override
    public ResponseResult<Void> checkHandle(ResponseResult<Void> responseResult, DeleteMenuGroupIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> doHandle(ResponseResult<Void> responseResult, DeleteMenuGroupIn in) {
        LambdaQueryWrapper<MenuGroupDto> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(MenuGroupDto::getgId, in.getgId());
        int i = menuGroupServiceDao.delete(queryWrapper);
        return responseResult;
    }

    @Override
    public ResponseResult<Void> respHandle(ResponseResult<Void> responseResult, DeleteMenuGroupIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> deleteMenuGroup(DeleteMenuGroupIn in) {
        ResponseResult<Void> result = new ResponseResult<>();
        return this.mainHandle(result, in);
    }
}
